<?php

declare (strict_types = 1);

namespace App\Dao;
use App\Model\AuthRole;

class AuthRoleDao
{
    use DaoTrait;
    use RbacTrait;

    public function __construct()
    {
        $this->driver = __CLASS__;
    }

    // 通过条件搜索分页角色
    public function searchByWherePage(int $pageSize, int $page, array $where = []) : array
    {
        return AuthRole::query()->where($where)->paginate(intval($pageSize),['*'],'page',$page)->toArray();
    }

    //找出角色的所有权限id
    public function rolePermissionByRoleID(int $role_id) : array
    {
        return static::permissionIdByRoleid($role_id);
    }

    //通过in删除权限
    public function delRoleByIds($where)
    {
        return AuthRole::query()->whereIn('id', $where)->delete();
    }
}